package com.boss.salary.service.impl;

import com.boss.common.util.DateUtils;
import com.boss.salary.dao.IReportTimeControlDao;
import com.boss.salary.entity.ReportTimeControl;
import com.boss.salary.service.IReportTimeControlService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;

@Service
public class ReportTimeControlServiceImpl implements IReportTimeControlService{

    /**
     * 引入日志框架常量
     */
    private final static Logger logger = LoggerFactory.getLogger(ReportTimeControlServiceImpl.class);

    @Autowired
    private IReportTimeControlDao iReportTimeControlDao;


    @Override
    public ReportTimeControl getReportTimeControl(String province) {
        return iReportTimeControlDao.getReportTimeControl(province);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void updateReportTimeControl(ReportTimeControl reportTimeControl) {
        if (StringUtils.isEmpty(reportTimeControl.getId())) {
            iReportTimeControlDao.insertReportTimeControl(reportTimeControl);
        }
        reportTimeControl.setCreateTime(String.valueOf(DateUtils.getCurrentTimeStamp()));
        reportTimeControl.setUpdateTime(String.valueOf(DateUtils.getCurrentTimeStamp()));
        iReportTimeControlDao.updateReportTimeControl(reportTimeControl);
    }
}
